#include <bits/stdc++.h>
using namespace std;

//双指针有交换，也有覆盖

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int n = nums.size();
        int length = 0;
        for(int i=0; i<n; ++i){
            if(nums[i]==val) continue;
            nums[length++] = nums[i];
        }
        return length;
    }
};